﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall;
using FlatRedBall.Graphics;

namespace TopDownShooter
{
    class Hud : PositionedObject
    {
        Text ammoText;
        Text weaponType;
        ProgressBar reloadingBar;
        public void Activity()
        {
            //Position = SpriteManager.Camera.Position;
            //Z = 0;
        }
        public Hud()
        {
            ammoText = TextManager.AddText("");
            ammoText.Scale = 3;
            ammoText.Spacing = 3;
            ammoText.AttachTo(this, false);
            ammoText.RelativeX = 30;
            ammoText.RelativeY = -30;
            weaponType = TextManager.AddText("");
            weaponType.Scale = 1.5f;
            weaponType.Spacing = 1.5f;
            weaponType.AttachTo(this, false);
            weaponType.RelativeX = 16;
            weaponType.RelativeY = -30;
            reloadingBar = new ProgressBar();
            reloadingBar.AttachTo(this, false);
            reloadingBar.RelativeX = 30;
            reloadingBar.RelativeY = -35;
            ParentRotationChangesPosition = false;
            ParentRotationChangesRotation = false;
        }
        public void Destroy()
        {
            TextManager.RemoveText(ammoText);
            TextManager.RemoveText(weaponType);
            reloadingBar.Destroy();
        }

        internal void SetAmmo(String type, int bulletsCurrentlyInClip, int clipSize)
        {
            ammoText.DisplayText = bulletsCurrentlyInClip + " | " + clipSize;
            weaponType.DisplayText = type;
        }
        internal void SetReloadingProgress(float secondsPassed, float reloadTime)
        {
            reloadingBar.setPercentage(secondsPassed / reloadTime);
            if (reloadTime <= secondsPassed)
                reloadingBar.setPercentage(0);
        }
    }
}
